
open Ast

let then_ambiguous_list func lst = 
	List.fold_left (fun t e -> t || func e) false lst

let rec then_ambiguous_sourceElement = function
	| AStatement(s) -> then_ambiguous_statement s
	(*| AFunctionDeclaration(funcDecl) -> then_ambiguous_functionDeclaration funcDecl *) (* Modif #1 *)
	
and then_ambiguous_statement = function
	| ABlock _ -> false
	| AVariableStatement _ -> false
	| AConstStatement _ -> false		(* Modif #2 *)
	| AFuncDeclaration _ -> false	(* Modif #1 *)
	| AIfStatement(ifStatement) -> then_ambiguous_ifStatement ifStatement
	| AIterationStatement(iterationStatement) -> then_ambiguous_iterationStatement iterationStatement
	| AWithStatement(withStatement) -> then_ambiguous_withStatement withStatement
	| ALabelledStatement(labelledStatement) -> then_ambiguous_labelledStatement labelledStatement
	| ASwitchStatement _ -> true
	| ATryStatement _ -> true
	| AEmptyStatement -> false
	| AExpressionStatement _ -> false
	| AContinueStatement _ -> false
	| ABreakStatement _ -> false
	| AReturnStatement _ -> false
	| AThrowStatement _ -> false
	| ADebuggerStatement -> false

and then_ambiguous_ifStatement = function
	| AIfElse(_, _, stmt2) -> then_ambiguous_statement stmt2
	| AIf(_, _) -> true

and then_ambiguous_iterationStatement = function
	| ADoWhile _ -> false
	| AWhile(_, stmt) ->
		then_ambiguous_statement stmt
	| AFor(_, _, _, stmt) ->
		then_ambiguous_statement stmt
	| AForIn(_, _, stmt) ->
		then_ambiguous_statement stmt
	| AForVar(_, _, _, _, stmt) ->
		then_ambiguous_statement stmt
	| AForVarIn(_, _, _, stmt) ->
		then_ambiguous_statement stmt
		
and then_ambiguous_withStatement (_, stmt) = 
	then_ambiguous_statement stmt

and then_ambiguous_labelledStatement (_, stmt) =
	then_ambiguous_statement stmt

